﻿using System;
using Util;

namespace IterationLife.Extensions.Dtos
{
    /// <summary>
    /// 资源
    /// </summary>
    public class Resources
    {
        /// <summary>
        /// 编号
        /// </summary>
        public Guid Id { get; set; }

        /// <summary>
        /// 大小
        /// </summary>
        public string Size { get; set; }

        /// <summary>
        /// 地址
        /// </summary>
        public string Address { get; set; }
    }

    /// <summary>
    /// 资源扩展
    /// </summary>
    public static class ResourcesExtension
    {
        /// <summary>
        /// 图片瘦身
        /// </summary>
        public static Resources ImageSlim(this Resources resources)
        {
            return new Resources
            {
                Id = resources.Id,
                Size = resources.Size,
                Address = resources.Address.IsEmpty() ? resources.Address : $"{resources.Address}?imageslim"
            };
        }
    }

}
